package com.it.travel.controller.admin;

import cn.hutool.core.bean.BeanUtil;
import com.it.travel.pojo.Role;
import com.it.travel.service.admin.AdminRoleService;
import com.it.travel.vo.Params.PageParams;
import com.it.travel.vo.Params.admin.*;
import com.it.travel.vo.Result;
import com.it.travel.vo.admin.AdminPermissionTreeVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/admin/role")
@CrossOrigin
public class AdminRoleController {
    @Resource
    private AdminRoleService adminRoleService;

    //    /
    @GetMapping("")
    public Result<?> getInfoPage(PageParams pageParams) {
        Result<?> result = adminRoleService.getInfoPage(pageParams);
        return result;
    }

    @PostMapping("/permission")
    public Result<?> savePermissionInfo(@RequestBody AdminRolePermissionAddParams adminRolePermissionAddParams) {
        Result<?> result = adminRoleService.savePermissionInfo(adminRolePermissionAddParams);
        return result;
    }

    @GetMapping("/permission")
    public Result<?> getPermissionInfo(@RequestParam("roleid") Integer roleid) {
        Result<?> result = adminRoleService.getPermissionInfo(roleid);
        return result;
    }


    @PostMapping("")
    public Result<?> save(@RequestBody AdminRoleParams adminProductParams) {
        Result<?> result = adminRoleService.save(adminProductParams);
//        return result;
        return result;
    }

    @PutMapping("/distribution")
    public Result<?> save(List<Integer> ids) {
        return null;
    }

    @DeleteMapping("/{id}")
    public Result<?> delete(@PathVariable("id") Integer id) {
        Result<?> result = adminRoleService.delete(id);
        return result;
    }

    @PutMapping("")
    public Result<?> update(@RequestBody AdminRoleUpdateParams adminRoleUpdateParams) {

        Result<?> result = adminRoleService.update(adminRoleUpdateParams);
        return result;
    }
//
//    @PostMapping("/deletebatch")
//    public Result<?> deletebatch(@RequestBody List<Integer> ids) {
//        Result<?> result = adminProductService.deletebatch(ids);
//        return result;
////        return null;
//    }
//
//    @PostMapping("/detail")
//    public Result<?> saveProductDetail(@RequestBody AdminProductDetailParams adminProductDetailParams) {
//        Result<?> result = adminProductService.saveProductDetail(adminProductDetailParams);
//        return result;
////        return null;
//    }
//
//    @GetMapping("/detail/{id}")
//    public Result<?> findProductDetail(@PathVariable("id") Integer id) {
//        Result<?> result = adminProductService.findProductDetail(id);
//        return result;
////        return null;
//    }
}
